# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Andy Postnikov <apostnikov@gmail.com>
pkgname=drupal7
pkgver=7.101
pkgrel=0
pkgdesc="An open source content management platform"
url="https://www.drupal.org/"
arch="noarch"
license="GPL-2.0-or-later"
_php=php82
depends="$_php-fpm
	$_php-bcmath
	$_php-ctype
	$_php-curl
	$_php-dom
	$_php-gd
	$_php-gmp
	$_php-iconv
	$_php-mbstring
	$_php-opcache
	$_php-openssl
	$_php-pcntl
	$_php-pdo_mysql
	$_php-pdo_sqlite
	$_php-session
	$_php-simplexml
	$_php-tokenizer
	$_php-xml
	"
makedepends="$depends_dev"
subpackages="$pkgname-doc"
pkggroups="www-data"
source="https://ftp.drupal.org/files/projects/drupal-$pkgver.tar.gz"

builddir="$srcdir/drupal-$pkgver"
options="!check" # This package not have testsuite

# secfixes:
#   7.91-r0:
#     - CVE-2022-26493
#   7.89-r0:
#     - CVE-2022-25271
#   7.86-r0:
#     - CVE-2021-41182
#     - CVE-2021-41183
#     - CVE-2016-7103
#     - CVE-2010-5312
#   7.82-r0:
#     - CVE-2021-32610
#   7.81-r0:
#     - CVE-2020-13672
#   7.78-r0:
#     - CVE-2020-36193
#   7.75-r0:
#     - CVE-2020-28948
#     - CVE-2020-28949
#   7.74-r0:
#     - CVE-2020-13671
#   7.73-r0:
#     - CVE-2020-13666
#   7.72-r0:
#     - CVE-2020-13663
#   7.70-r0:
#     - CVE-2020-11022
#     - CVE-2020-11023
#     - CVE-2020-13662
#   7.66-r0:
#     - CVE-2018-11358
#   7.65-r0:
#     - CVE-2019-6341
#   7.62-r0:
#     - CVE-2018-1000888
#   7.59-r0:
#     - CVE-2018-7602
#   7.58-r0:
#     - CVE-2018-7600

package() {
	mkdir -p "$pkgdir"/var/lib/$pkgname \
		"$pkgdir"/usr/share/webapps/$pkgname/ \
		"$pkgdir"/etc/$pkgname/default \
		"$pkgdir"/usr/share/doc/"$pkgname"
	# move drupals sites directory where all module/themes/libaries reside
	mv sites "$pkgdir"/var/lib/$pkgname/
	mkdir -p "$pkgdir"/var/lib/$pkgname/sites/default/files
	# move drupals default config to sysconfig dir.
	# multisite setups are advanced and needs user configuration
	mv $pkgdir/var/lib/$pkgname/sites/default/default.settings.php \
		"$pkgdir"/etc/$pkgname/default/
	ln -s /etc/"$pkgname"/default/settings.php \
		$pkgdir/var/lib/$pkgname/sites/default/settings.php
	mv $pkgdir/var/lib/$pkgname/sites/example.sites.php \
		"$pkgdir"/etc/$pkgname/
	ln -sf /etc/"$pkgname"/sites.php \
		$pkgdir/var/lib/$pkgname/sites/sites.php
	# move uneeded txt files to doc package
	for file in *.txt; do
		[ "$file" != "robots.txt" ] && mv $file \
			"$pkgdir"/usr/share/doc/"$pkgname"/
	done
	# make drupal a webapp
	mv ./* "$pkgdir"/usr/share/webapps/$pkgname/
	ln -sf /var/lib/$pkgname/sites \
		"$pkgdir"/usr/share/webapps/$pkgname/sites
	# make sure the webserver can access/write to needed files/directories
	chgrp -R www-data "$pkgdir"/var/lib/$pkgname \
		"$pkgdir"/etc/$pkgname
	chmod g+w "$pkgdir"/var/lib/$pkgname/sites/all/* \
		"$pkgdir"/var/lib/$pkgname/sites/default/files
}

sha512sums="
7abf087e80d26301e81e6235e88df4842a1ff3691d46850cbcce0da15091691b43e2d3b4da7a4661e153c272f9a9c88e6bf585030365ae349f665ce82c92bd13  drupal-7.101.tar.gz
"
